﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Public;
using BLL;

namespace QLNhanKhau
{
    public partial class frmNhanKhau : Form
    {
        private int _MaNK;

        public int MaNK
        {
            get { return _MaNK; }
            set { _MaNK = value; }
        }
        private int _MaND;

        public int MaND
        {
            get { return _MaND; }
            set { _MaND = value; }
        }
        

        public frmNhanKhau()
        {
            InitializeComponent();
        }

        public frmNhanKhau(int _MaNK,int _MaND)
        {
            InitializeComponent();
            this._MaNK = _MaNK;
            this._MaND = _MaND;
        }


        private void frmNhanKhau_Load(object sender, EventArgs e)
        {

            MessageBox.Show(_MaNK.ToString());
            NhanKhauPublic nk = NhanKhauBLL.LoadNhanKhauByMaNK(_MaNK);
            
            txtHoTen.Text = nk.HoTen;
            txtDiaChi.Text = SoHoKhauBLL.LoadDiaChiSHKByMaNK(_MaNK);
            txtQuocTich.Text = QuocTichBLL.LoadQuocTichByMaQT(nk.MaQT).TenQuocTich.ToString();
            txtDanToc.Text = DanTocBLL.LoadDanTocByMaDT(nk.MaDT).TenDanToc.ToString();
            txtTonGiao.Text = TonGiaoBLL.LoadTonGiaoByMaTG(nk.MaTG).TenTonGiao.ToString();
            txtTrinhDo.Text = TrinhDoBLL.GetTrinhDoByMaTD(nk.MaTD).TenTrinhDo.ToString();
            txtChucVu.Text = ChucVuBLL.LoadChucVuByMaCV(NguoiDungBLL.LoadNguoiDungByMaND(_MaND).MaCV).TenChucVu.ToString();
            dateNgaySinh.Value = (DateTime)nk.NgaySinh;

            NguoiDungPublic nd=NguoiDungBLL.LoadNguoiDungByMaND(_MaND);

            dateBatDau.Value = (DateTime)nd.ThoiGianBatDau;
            dateKetThuc.Value = (DateTime)nd.ThoiGianKetThuc;
            if (nd.TinhTrang == true)
                cboxTinhTrang.Checked = false;
            else
                cboxTinhTrang.Checked = true;

            //      txtDiaChi.Text = SoHoKhauBLL.LoadDiaChiByMaNK(_MaNK).SoNha + ", " + SoHoKhauBLL.LoadDiaChiByMaNK(_MaNK).Duong + ", " + SoHoKhauBLL.LoadDiaChiByMaNK(_MaNK).KhuPho + ", " + ThietLapBLL.LoadDiaChiByMaNK(_MaNK).ToString();

            //if ((bool)nk.GioiTinh ? stbGioiTinh.Value = true : stbGioiTinh.Value = false) 

            if (nk.GioiTinh == true)
                stbGioiTinh.Value = true;
            else
                stbGioiTinh.Value = false;

            // (nk.GioiTinh == true) ? (stbGioiTinh.Value = true) : (stbGioiTinh.Value = false);

        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
